home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / Goodies / Wiper / regwiper.bas < prev    next >
BASIC Source File  |  1997-04-03  |  1KB  |  37 lines

  1. Attribute VB_Name = "MRegWiper"
  2. Option Explicit
  3.  
  4. Declare Function OpenProcess Lib "kernel32" ( _
  5.     ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
  6.     ByVal dwProcessId As Long) As Long
  7. Declare Function GetExitCodeProcess Lib "kernel32" ( _
  8.     ByVal hProcess As Long, lpExitCode As Long) As Long
  9. Declare Function CloseHandle Lib "kernel32" ( _
  10.     ByVal hObject As Long) As Long
  11. Declare Function WritePrivateProfileString Lib "kernel32" _
  12.     Alias "WritePrivateProfileStringA" (ByVal AppName As String, _
  13.     ByVal KeyName As String, ByVal KeyDefault As String, _
  14.     ByVal FileName As String) As Long
  15. Const STILL_ACTIVE = &H103
  16. Const PROCESS_QUERY_INFORMATION = &H400
  17.  
  18. Sub Main()
  19.     Dim id As Long
  20.     id = Shell("regsvr32.exe /s wiper.dll", vbHide)
  21.     Do While IsRunning(id)
  22.         DoEvents
  23.     Loop
  24.     Call WritePrivateProfileString("Add-Ins32", "AddInDebugWiper.Connect", "1", "VBADDIN.INI")
  25. End Sub
  26.  
  27. Function IsRunning(idProg As Long) As Boolean
  28.     Dim idProc As Long, iRet As Long
  29.     ' Get process handle
  30.     idProc = OpenProcess(PROCESS_QUERY_INFORMATION, False, idProg)
  31.     ' Check status of process
  32.     If idProc <> 0 Then GetExitCodeProcess idProc, iRet
  33.     IsRunning = (iRet = STILL_ACTIVE)
  34.     CloseHandle idProc
  35. End Function
  36.  
  37.